//渲染轮播图图片
function renderImgList(Dom, carousels) {
    for (let i = 0; i <= carousels.length - 1; i++) {
        Dom.innerHTML += `
        <div class="swiper-slide"><img src="${carousels[i].url}" alt=""></div>
        `
    }
}

//创建轮播图
function NewSwiper(Node, userParams) {
    const DefaultCase = {
        direction: 'horizontal', // 垂直切换选项
        loop: true, // 循环模式选项
        // 前进后退按钮
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true,   //分页器可点击
        },
        //自动轮播，在操作完轮播图后恢复自动轮播
        autoplay: {
            disableOnInteraction: false
        },
        //设置轮播速度
        speed: 1000,
    }
    const params = { ...DefaultCase, ...userParams };
    console.log(params);
    return new Swiper(Node, params)
}

export { renderImgList, NewSwiper };